<?php
class UserInformation extends EpiTwitter {
	public $Id;
	public $AvatarUrl;
	public $Token;
	public $Secret;
	private $Dao = null;

	function UserInformation($Id = null){
		parent::__construct();
		$this->Id = $Id;
		if($Id != null){
			$this->Dao = new UserInformationDAO($this->Id);
			
		}
	}
	
	function exists(){
		if($this->Dao == null){
			return false;
		}else{
			return true;
		}
	}
	
	function getUserInformation(){
		
	}
	
	function saveUser($objResponseUser){
		$this->Dao = new UserInformationDAO($objResponseUser->id);
		if($this->Dao->Id == NULL){
			$this->Dao->Id = $objResponseUser->id;
			$this->Dao->Token = $this->oauth_token;
			$this->Dao->Secret = $this->oauth_token_secret;
			$this->Dao->save();
		}
		$this->data = $objResponseUser;
	}

	
}


class UserInformationDAO extends ApplicationDAO {
	public $Id;
	public $Token;
	public $Secret;
	
	function UserInformationDAO($Id = null){
		parent::ApplicationDAO();
		if($Id !== NULL){
			$query = "SELECT * FROM tbUser where id = '$Id'";
			$objResult = $this->executeQuery($query);
			if ($objResult){
				$this->parseObject($objResult);
			}
		}
	}
	
	function save(){
		$query = "INSERT INTO tbUser (id,token,secret) VALUES ($this->Id,'$this->Token','$this->Secret')";
		return $this->executeQuery($query);
	}
	
}